package artid.com.arttogo.bean;

import android.text.TextUtils;

import org.json.JSONObject;

import java.io.Serializable;

public class UserItem extends AppItem implements Serializable {
	public static final long serialVersionUID = 1L;
	private String token = "";// 登录返回字段
	private String realname;
	private String mobile;
	private String headurl;
	private boolean isLogin = false;
	private String uid;
	private Boolean isWx = false,isQQ =false;

	@Override
	public void parse(JSONObject obj) {
		if (null == obj) {
			return;
		}
		token = obj.optString("token");
		realname = obj.optString("realname");
		mobile = obj.optString("mobile");
		headurl = obj.optString("headurl");
		uid = obj.optString("uid");
		isLogin = true;
		isWx = obj.optBoolean("weixin");
		isQQ = obj.optBoolean("qq");
	}

	public void parse(UserItem data) {
		if (data == null) {
			return;
		}
		if (!TextUtils.isEmpty(data.token)) {
			this.token = data.token;
		}
		if (!TextUtils.isEmpty(data.realname)) {
			this.realname = data.realname;
		}
		if (!TextUtils.isEmpty(data.mobile)) {
			this.mobile = data.mobile;
		}
		if (!TextUtils.isEmpty(data.headurl)) {
			this.headurl = data.headurl;
		}
		if (!TextUtils.isEmpty(data.uid)) {
			this.uid = data.uid;
		}
		if (data.isQQ!=null) {
			this.isQQ = data.isQQ;
		}
		if (data.isWx!=null) {
			this.isWx = data.isWx;
		}
		isLogin = true;

	}

	
	
	public Boolean getIsWx() {
		return isWx;
	}

	public void setIsWx(Boolean isWx) {
		this.isWx = isWx;
	}

	public Boolean getIsQQ() {
		return isQQ;
	}

	public void setIsQQ(Boolean isQQ) {
		this.isQQ = isQQ;
	}

	public String getUid() {
		return uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getHeadurl() {
		return headurl;
	}

	public void setHeadurl(String headurl) {
		this.headurl = headurl;
	}

	public boolean isLogin() {
		return isLogin;
	}

	public void setLogin(boolean isLogin) {
		this.isLogin = isLogin;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public String toString() {
		return "UserItem [token=" + token + ", realname=" + realname
				+ ", mobile=" + mobile + ", headurl=" + headurl + ", isLogin="
				+ isLogin + ", uid=" + uid + "]";
	}

	

}
